<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>供品</title>
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no, email=no" />
    <script type="text/javascript" src="{MODULE_URL}public/fo/js/flexible.js"></script>
    <script type="text/javascript" src="{MODULE_URL}public/fo/js/pageLoading.js"></script>
    <link type="text/css" rel="stylesheet" href="{MODULE_URL}public/fo/css/tribute.css">
    <script src="{MODULE_URL}public/fo/js/jquery.js"></script>
    <script src="{MODULE_URL}public/fo/js/layer.js" type="text/javascript"></script>

    <script>
        function show_loading(){
            layer.load(1);
        }

        function hide_loading(){
            layer.closeAll();
        }
    </script>

</head>
<body>
<div class="tribute">
    <div class="chooseRow">
        <div class="flower ch" data-name="花篮">
            <img id="flower_kong" src="{MODULE_URL}public/fo/images/hp_no2.png" alt="空花篮">
        </div>
        <div class="stove ch" data-name="香炉">
            <img id="def_sweet_kong" src="{MODULE_URL}public/fo/images/xl_no2.png" alt="空香炉">
        </div>
        <div class="fruit ch" data-name="果盘">
            <img id="fruit_kong" src="{MODULE_URL}public/fo/images/gp_no2.png" alt="空果盘">
        </div>
    </div>

    <div class="chooseBox">
        <!-- 花篮 -->
        <ul class="chooselist flower">
        {loop $hualan $v}
            <li data-goodsname="{$v['title']}">
               <img src="../attachment/{$v['image']}" alt="{$v['title']}" {if $v['prise'] == '0.00'}money="0.00"{else} money="{$v['prise']}"{/if}>
						<span class="money">{if $v['prise'] == '0.00'}免费{else}{$v['prise']}{/if}</span>
            </li>
        {/loop}

        </ul>
        <!-- 花篮 -->
        <!-- 香炉 -->
        <ul class="chooselist stove">
        {loop $xianglu $v}
            <li data-goodsname="{$v['title']}">
               <img src="../attachment/{$v['image']}" alt="{$v['title']}" {if $v['prise'] == '0.00'}money="0.00"{else} money="{$v['prise']}"{/if}>
						<span class="money">{if $v['prise'] == '0.00'}免费{else}{$v['prise']}{/if}</span>
            </li>
        {/loop}

        </ul>
        <!-- 香炉 -->
        <!-- 果盘 -->
        <ul class="chooselist fruit">
        {loop $guopan $v}
            <li data-goodsname="{$v['title']}">
               <img src="../attachment/{$v['image']}" alt="{$v['title']}" {if $v['prise'] == '0.00'}money="0.00"{else} money="{$v['prise']}"{/if}>
						<span class="money">{if $v['prise'] == '0.00'}免费{else}{$v['prise']}{/if}</span>
            </li>
        {/loop}
        </ul>
        <!-- 果盘 -->
    </div>
    <div class="chooseBtn">
        <a href="javascript:;" title="确定贡品"></a>
    </div>
</div>


<!-- 弹窗 -->
<div class="pagetips" id="pagetips">
    <div class="title">随喜赞叹</div>
    <div class="cont">
        您的供佛发心，付费贡品善款皆用于本系统技 术研发和供养寺院师傅，若您经济困难可使用 免费贡品，心诚则灵
    </div>
    <ul class="ptbtn">
    <!-- 此处先不写支付 -->
         <li><a href="javascript:;" class="topay">好</a></li> 
        <!-- <li><a href="{php echo $this->createMobileUrl('gong',array('status'=>1))}" class="topay">好</a></li> -->
    </ul>
</div>
<!-- 弹窗 -->

<script>
    $(function(){


        $('ul.chooselist li').on('click', function(){
            var index = $(this).parent().index(),
                    src = $(this).find('img').attr('src');
            var alt = $(this).find('img').attr('alt');
            var money = $(this).find('img').attr('money');
            var name= $(this).attr('data-goodsname');
            $(this).parents('.chooseBox').prev().find('.ch').eq(index).addClass('change').find('img').attr('src', src);
            $(this).parents('.chooseBox').prev().find('.ch').eq(index).addClass('change').find('img').attr('alt', alt);
            $(this).parents('.chooseBox').prev().find('.ch').eq(index).addClass('change').find('img').attr('money', money);
            $(this).parents('.chooseBox').prev().find('.ch').eq(index).addClass('change').find('img').attr('data-goodsname', name);

        });
        $('.chooseBtn>a').on('click', function(){

            var flag = true, names = "",goods="";
            $('.chooseRow>.ch').each(function(index, el) {
                if(!$(this).hasClass('change')){
                    var name = $(this).attr('data-name');
                    names += name + "，";
                    flag = false;
                }
            });
            /* upload the choose no */
            var flower_name = $('#flower_kong').attr('data-goodsname');
            var sweet_name = $('#def_sweet_kong').attr('data-goodsname');
            var fruit_name = $('#fruit_kong').attr('data-goodsname');
            var flower_no = $('#flower_kong').attr('alt');
            var sweet_no = $('#def_sweet_kong').attr('alt');
            var fruit_no = $('#fruit_kong').attr('alt');
            var flower_money = $('#flower_kong').attr('money');
            var sweet_money = $('#def_sweet_kong').attr('money');
            var fruit_money = $('#fruit_kong').attr('money');
            var total_money = Number(flower_money) + Number(sweet_money) + Number(fruit_money);
            var goodsid=flower_no+','+sweet_no+','+fruit_no;
            var goods=flower_name+','+sweet_name+','+fruit_name;
            if(flag) {
                if(total_money>0){
                    $('#pagetips').show();
                    return
                }else{
                }
            }else {
                names = names.substr(0,names.length-1);
                alert("您还没选择："+names);
                flag = true;
                names = "";
            }
        });


    });
</script>
<script>
    wx.ready(function(){
        $('.topay').click(function(){
            var id = $(this).data('id');
            $.get("",{id:id,act:'src'},function(data){
                if(data.status == 8){
                    $.toast(data.message,2000,function(){});
                    return '';
                }
                if(data.status == 0){
                    playData(data);
                }else{
                //
                    wx.chooseWXPay({
                        timestamp: data.timeStamp,
                        nonceStr: data.nonceStr,
                        package: data.package,
                        signType: data.signType,
                        paySign: data.paySign,
                        success: function (res) {
                            if(res.errMsg == 'chooseWXPay:ok') {
                                data.act == 'paySuccess';
                                $.post("",{act:'paySuccess',listen_id:data.listen_id},function(d){
                                    if(d.status == 1){
                                        playData(d);
                                    }else{
                                        $.toast('系统错误',2000,'cancel');
                                    }
                                },'json');
                            }else{
                                window.location.href = "{php echo $_W['siteurl']}";
                            }
                        }
                    });
                    //
                }
            },'json');
        });
    });
</script>
</body>

</html>